package cn.itsource.shiro.utils;

import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * 免密登录
 * 自定义token，继承UsernamePasswordToken
 * 声明一个loginType，用于登录判断是否是免密登录
 */
public class MyUsernamePasswordToken extends UsernamePasswordToken {

    private String loginType;

    public MyUsernamePasswordToken() {
    }

    /**
     * 账号密码登录
     * @param username
     * @param password
     * @param rememberMe
     * @param host
     */
    public MyUsernamePasswordToken(String username, String password,
                       boolean rememberMe, String host,String loginType) {
        super(username, password, rememberMe, host);
        this.loginType = loginType;
    }

    public MyUsernamePasswordToken(String username,String password){
        super(username,password,false,null);
        this.loginType = LoginType.PASSWORD;
    }

    /**免密登录*/
    public MyUsernamePasswordToken(String username) {
        super(username, "", false, null);
        this.loginType = LoginType.NOPASSWD;
    }

    public String getLoginType() {
        return loginType;
    }

    public void setLoginType(String loginType) {
        this.loginType = loginType;
    }
}
